package com.orhon.smartcampus.modules.base.fetcher;

import com.orhon.smartcampus.modules.base.mutation.*;
import graphql.schema.idl.RuntimeWiring;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BaseFetchersLoader {

    @Autowired
    DictionarysFetcher dictionarysFetcher;
    @Autowired
    DictionaryFetcher dictionaryFetcher;
    @Autowired
    GradesFetcher gradesFetcher;
    @Autowired
    GradeFetcher gradeFetcher;
    @Autowired
    PeriodsFetcher periodsFetcher;
    @Autowired
    PeriodFetcher periodFetcher;
    @Autowired
    RegionsFetcher regionsFetcher;
    @Autowired
    RegionFetcher regionFetcher;
    @Autowired
    SchoolsFetcher schoolsFetcher;
    @Autowired
    EsSchoolsFetcher esSchoolsFetcher;
    @Autowired
    SchoolFetcher schoolFetcher;
    @Autowired
    SchoolTypesFetcher schoolTypesFetcher;
    @Autowired
    SchoolTypeFetcher schoolTypeFetcher;
    @Autowired
    SubjectsFetcher subjectsFetcher;
    @Autowired
    SubjectFetcher subjectFetcher;

    @Autowired
    TextbooksFetcher textbooksFetcher;

    @Autowired
    TextbookChaptersFetcher textbookChaptersFetcher;

    @Autowired
    AddDictionaryMutation addDictionaryMutation;

    @Autowired
    DeleteDictionaryMutation deleteDictionaryMutation;

    @Autowired
    AddSubjectMutation addSubjectMutation;

    @Autowired
    DeleteSubjectMutation deleteSubjectMutation;

    @Autowired
    AddPeriodMutation addPeriodMutation;

    @Autowired
    DeletePeriodMutation deletePeriodMutation;

    @Autowired
    AddSchoolMutation addSchoolMutation;

    @Autowired
    DeleteSchoolMutation deleteSchoolMutation;

    @Autowired
    AddRegionMutation addRegionMutation;

    @Autowired
    DeleteRegionMutation deleteRegionMutation;

    @Autowired
    AddGradeMutation addGradeMutation;

    @Autowired
    DeleteGradeMutation deleteGradeMutation;
    
    @Autowired
    private SchoolInfoFetcher schoolInfoFetcher;
    
    public void LoadFetchers(RuntimeWiring.Builder builder){


        //users -> data
        builder.type("Query" , t->t.dataFetcher("Dictionarys" , dictionarysFetcher));
        builder.type("Query" , t->t.dataFetcher("Dictionary" , dictionaryFetcher));
        builder.type("Query" , t->t.dataFetcher("grades" , gradesFetcher));
        builder.type("Query" , t->t.dataFetcher("grade" , gradeFetcher));
        builder.type("Query" , t->t.dataFetcher("periods" , periodsFetcher));
        builder.type("Query" , t->t.dataFetcher("period" , periodFetcher));
        builder.type("Query" , t->t.dataFetcher("schools" , schoolsFetcher));
        builder.type("Query" , t->t.dataFetcher("esSchools" , esSchoolsFetcher));
        builder.type("Query" , t->t.dataFetcher("school" , schoolFetcher));
        builder.type("Query" , t->t.dataFetcher("regions" , regionsFetcher));
        builder.type("Query" , t->t.dataFetcher("region" , regionFetcher));
        builder.type("Query" , t->t.dataFetcher("schoolTypes" , schoolTypesFetcher));
        builder.type("Query" , t->t.dataFetcher("schoolType" , schoolTypeFetcher));
        builder.type("Query" , t->t.dataFetcher("subjects" , subjectsFetcher));
        builder.type("Query" , t->t.dataFetcher("subject" , subjectFetcher));
        builder.type("Query" , t->t.dataFetcher("schoolInfo" , schoolInfoFetcher));
        //教材
        builder.type("Query" , t->t.dataFetcher("textbooks" , textbooksFetcher));
        //教材章节（知识点）
        builder.type("Query" , t->t.dataFetcher("textbookChapters" , textbookChaptersFetcher));


        builder.type("Mutation" , t->t.dataFetcher("addDictionary" , addDictionaryMutation));
        builder.type("Mutation" , t->t.dataFetcher("deleteDictionary" , deleteDictionaryMutation));
        builder.type("Mutation" , t->t.dataFetcher("addSubject" , addSubjectMutation));
        builder.type("Mutation" , t->t.dataFetcher("deleteSubject" , deleteSubjectMutation));
        builder.type("Mutation" , t->t.dataFetcher("addPeriod" , addPeriodMutation));
        builder.type("Mutation" , t->t.dataFetcher("deletePeriod" , deletePeriodMutation));
        builder.type("Mutation" , t->t.dataFetcher("addSchool" , addSchoolMutation));
        builder.type("Mutation" , t->t.dataFetcher("deleteSchool" , deleteSchoolMutation));
        builder.type("Mutation" , t->t.dataFetcher("addRegion" , addRegionMutation));
        builder.type("Mutation" , t->t.dataFetcher("deleteRegion" , deleteRegionMutation));
        builder.type("Mutation" , t->t.dataFetcher("addGrade" , addGradeMutation));
        builder.type("Mutation" , t->t.dataFetcher("deleteGrade" , deleteGradeMutation));


    }


}
